home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SOUND.SWG / 0002_DETCADLB.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  48 lines

  1. Uses
  2.   Crt; (* Crt Needed For Delay Routine *)
  3.  
  4. Function AdlibCard : Boolean;
  5.  (* Routine to determine if a Adlib compatible card is installed *)
  6. Var
  7.   Val1,Val2 : Byte;
  8. begin
  9.   Port[$388] := 4;      (* Write 60h to register 4 *)
  10.   Delay(3);             (* Which resets timer 1 and 2 *)
  11.   Port[$389] := $60;
  12.   Delay(23);
  13.   Port[$388] := 4;      (* Write 80h to register 4 *)
  14.   Delay(3);             (* Which enables interrupts *)
  15.   Port[$389] := $80;
  16.   Delay(23);
  17.   Val1 := Port[$388];   (* Read status Byte *)
  18.   Port[$388] := 2;      (* Write ffh to register 2 *)
  19.   Delay(3);             (* Which is also Timer 1 *)
  20.   Port[$389] := $FF;
  21.   Delay(23);
  22.   Port[$388] := 4;      (* Write 21h to register 4 *)
  23.   Delay(3);             (* Which will Start Timer 1 *)
  24.   Port[$389] := $21;
  25.   Delay(85);            (* wait 85 microseconds *)
  26.   Val2 := Port[$388];   (* read status Byte *)
  27.   Port[$388] := 4;      (* Repeat the first to steps *)
  28.   Delay(3);             (* Which will reset both Timers *)
  29.   Port[$389] := $60;
  30.   Delay(23);
  31.   Port[$388] := 4;
  32.   Delay(3);
  33.   Port[$389] := $80;    (* Now test the status Bytes saved *)
  34.   If ((Val1 And $e0) = 0) And ((Val2 And $e0) = $c0) Then
  35.     AdlibCard := True    (* Card was found *)
  36.   Else
  37.     AdlibCard := False;  (* No Card Installed *)
  38. end;
  39.  
  40. begin
  41.   ClrScr;                       (* Clear the Screen *)
  42.   Write(' Adlib Card ');        (* Prepare Response *)
  43.   If AdlibCard Then
  44.     Writeln( 'Found!')           (* There is one *)
  45.   Else
  46.     Writeln('Not Found!');       (* Not! *)
  47. end.
  48.